package com.eeepay.eeepay_v2.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.eeepay.eeepay_v2.R;
import com.eeepay.v2_library.ui.ABBaseActivity;
import com.eeepay.v2_library.view.LeftRightText;

/**
 * 描述：申请详情页面
 * 作者：zhuangzeqin
 * 时间: 2017/7/21-10:10
 * 邮箱：zzq@eeepay.cn
 */
public class ApplyforDetailedInfoActivity extends ABBaseActivity implements View.OnClickListener {
    private Button btn_immediate;//立即处理
    private LeftRightText lrv_applyTime;//申请时间
    private LeftRightText lrv_agentName;//商户名称
    private LeftRightText lrv_agentNo;//商户号
    private LeftRightText lrv_deviceName;//机具类型
    private LeftRightText lrv_agent;//所属代理商名称
    private LeftRightText lrv_agentNumber;//所属代理商编号
    private LeftRightText lrv_agentOne;//一级代理商
    private LeftRightText lrv_consigneePhone;//一级代理商
    private LeftRightText lrv_agentOneNO;//一级代理商编号
    private LeftRightText lrv_handleSNNo;//下发机具的sn号
    private LeftRightText lrv_handleForce;//是否强制下发机具
    private EditText lrv_consigneeAddress;//收货人地址
    private LeftRightText lrv_handleState;//处理状态
    private LeftRightText lrv_handleTime;//处理时间
    private EditText lrv_handleRemarks;//处理备注
    private String mRecord_id;//记录id
    private String agent_no_parent;//所属代理商编号
    private String agentNoOne;//一级代理商编号
    private String merchantNo;//商户编号
    private String needOperation;//是否显示处理按钮
    private String status;//状态 0:待直属处理  1:已处理  2:待一级处理
    @Override
    protected int getLayoutId() {
        return R.layout.activity_applyfor_detailed_info;
    }

    @Override
    protected void initWidget() {
        btn_immediate = getViewById(R.id.btn_immediate);//处理按钮
        //------------------页面详情字段-----------------------
        lrv_applyTime = getViewById(R.id.lrv_applyTime);//申请时间
        lrv_agentName = getViewById(R.id.lrv_agentName);//商户名称
        lrv_agentNo = getViewById(R.id.lrv_agentNo);//商户号

        lrv_deviceName = getViewById(R.id.lrv_deviceName);//机具类型
        lrv_agent = getViewById(R.id.lrv_agent);//所属代理商名称
        lrv_agentNumber = getViewById(R.id.lrv_agentNumber);//所属代理商编号
        lrv_agentOne = getViewById(R.id.lrv_agentOne);//一级代理商
        lrv_agentOneNO = getViewById(R.id.lrv_agentOneNO);//一级代理商编号
        lrv_handleSNNo = getViewById(R.id.lrv_handleSNNo);//下发机具的sn号
        lrv_handleForce = getViewById(R.id.lrv_handleForce);//是否强制下发机具

        lrv_consigneePhone = getViewById(R.id.lrv_consigneePhone);//收货人手机
        lrv_consigneeAddress = getViewById(R.id.lrv_consigneeAddress);//收货人地址

        lrv_handleState = getViewById(R.id.lrv_handleState);//处理状态

        lrv_handleTime = getViewById(R.id.lrv_handleTime);//处理时间
        lrv_handleRemarks = getViewById(R.id.lrv_handleRemarks);//处理备注
        //------------ Grpc 生成的对象没有实现Serializable or Parcelable 接口 获取从传递过来的参数只能一个一个取-------------------
        mRecord_id = bundle.getString("record_id", "");//*************记录id;需要传给后台处理的******************
        needOperation = bundle.getString("needOperation", "");//是否显示处理按钮
        String createTime = bundle.getString("createTime", "");//申请时间
        String merchantName = bundle.getString("merchantName", "");//商户名称
//        String merchantNo = bundle.getString("merchantNo", "");//商户号
        String bpName = bundle.getString("bpName", "");//机具类型
        String agentNameParent = bundle.getString("agentNameParent", "");//所属代理商名称
        String agentNameOne = bundle.getString("agentNameOne", "");//一级代理商

        String mobilephone = bundle.getString("mobilephone", "");//收货人手机
        String address = bundle.getString("address", "");//收货人地址
        status = bundle.getString("status", "");//状态 0:待直属处理  1:已处理  2:待一级处理

        String updateTime = bundle.getString("updateTime", "");//处理时间
        String remark = bundle.getString("remark", "");//处理备注
        agent_no_parent= bundle.getString("agentNoParent", "");//直属代理商编号
        agentNoOne= bundle.getString("agentNoOne", "");//一级代理商编号
        merchantNo= bundle.getString("merchantNo", "");//商户编号
        String isForce = bundle.getString("isForce", "");//是否强制下发
        String sn = bundle.getString("sn", "无");//机具的sn
        //------------ 字段开始赋值------------------------
        lrv_agentOneNO.setRightText(agentNoOne);
        lrv_agentNumber.setRightText(agent_no_parent);
        lrv_handleSNNo.setRightText(sn);
        lrv_handleForce.setRightText(isForce);

        lrv_applyTime.setRightText(createTime);
        lrv_agentName.setRightText(merchantName);
        lrv_agentNo.setRightText(merchantNo);

        lrv_deviceName.setRightText(bpName);
        lrv_agent.setRightText(agentNameParent);
        lrv_agentOne.setRightText(agentNameOne);

        lrv_consigneePhone.setRightText(mobilephone);
        lrv_consigneeAddress.setText(address);
        lrv_handleState.setRightText(status);

        lrv_handleTime.setRightText(updateTime);
        lrv_handleRemarks.setText(remark);


    }

    @Override
    protected void eventOnClick() {
        /** 是否需要处理(Y需要/N不需要) **/
        if (needOperation.equals("Y"))
        {
            btn_immediate.setVisibility(View.VISIBLE);
        }
        else
        {
            btn_immediate.setVisibility(View.GONE);
        }
        btn_immediate.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_immediate:
                Bundle bundle = new Bundle();
                bundle.putString("record_id",mRecord_id);//记录id
                //商户直属代理商与一级代理商 要传过去 做为判断
                bundle.putString("agent_no_parent",agent_no_parent);//所属代理商编号
                bundle.putString("agentNoOne",agentNoOne);//一级代理商编号
                bundle.putString("merchantNo",merchantNo);//商户号
                bundle.putString("status",status);//状态 0:待直属处理  1:已处理  2:待一级处理
                goActivity(HandleApplyForActivity.class,bundle);
                break;
            default:
                break;
        }
    }
}
